<?php
/**
 * Person's form
 *
 * @category    IPB_CMS
 * @package     Application_Module_Admin
 * @subpackage  Form
 * @copyright   Copyright (c) 2009 IPB CMS <http://ipb-cms.googlecode.com/>
 * @license     http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
 * @author      Henrique Moody <henriquemoody@gmail.com>
 */
class Admin_Form_Person extends App_Form
{

    /**
     * Initialize form
     *
     * @return void
     */
    public function init()
    {
        // First name field
        $this->addElement('text', 'personFirstName', array(
            'label' => 'First name',
            'maxlength' => 45,
            'required' => true,
            'validators' => array(
                array('StringLength', array(3, 45))
            ),
            'filters' => array(
                'StringTrim'
            )
        ));
        // Last name field
        $this->addElement('text', 'personLastName', array(
            'label' => 'Last name',
            'maxlength' => 45,
            'required' => true,
            'validators' => array(
                array('StringLength', array(3, 45))
            ),
            'filters' => array(
                'StringTrim'
            )
        ));
        // Person's type select
        $this->addElement('select', 'personType', array(
            'label' => 'Type',
            'required' => true,
            'multiOptions' => $this->_getOptionsTypes()
        ));
        // Person's status select
        $this->addElement('select', 'personStatus', array(
            'label' => 'Status',
            'required' => true,
            'multiOptions' => $this->_getOptionsStatus()
        ));
        // Submit button
        $this->addElement('submit', $this->getName() . '_submit', array(
            'label' => 'Send',
            'ignore' => true
        ));
    }

    /**
     * Returns an array of person's types for the 'personType' field
     *
     * @return array
     */
    protected function _getOptionsTypes()
    {
        $options = array();
        $options[]                               = 'Choose the person\'s type';
        $options[Model_Person::TYPE_CONGREGATED] = 'Congregated';
        $options[Model_Person::TYPE_MEMBER]      = 'Member';
        return $options;
    }

    /**
     * Returns an array of person's status for the 'personStatus' field
     *
     * @return array
     */
    protected function _getOptionsStatus()
    {
        $options = array();
        $options[]                                 = 'Choose the person\'s status';
        $options[Model_Person::STATUS_COMMUNION]   = 'Communion';
        $options[Model_Person::STATUS_DISCIPLINED] = 'Disciplined';
        $options[Model_Person::STATUS_EXCLUDED]    = 'Excluded';
        return $options;
    }

}
